package com.ruoyi.environment.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.environment.mapper.OpmEnvAccidentMapper;
import com.ruoyi.environment.domain.OpmEnvAccident;
import com.ruoyi.environment.service.IOpmEnvAccidentService;

/**
 * 环保事故Service业务层处理
 *
 * @author cjie
 * @date 2021-07-23
 */
@Service
public class OpmEnvAccidentServiceImpl implements IOpmEnvAccidentService {
    @Autowired
    private OpmEnvAccidentMapper opmEnvAccidentMapper;

    /**
     * 查询环保事故
     *
     * @param id 环保事故ID
     * @return 环保事故
     */
    @Override
    public OpmEnvAccident selectOpmEnvAccidentById(Long id) {
        return opmEnvAccidentMapper.selectOpmEnvAccidentById(id);
    }

    /**
     * 查询环保事故列表
     *
     * @param opmEnvAccident 环保事故
     * @return 环保事故
     */
    @Override
    public List<OpmEnvAccident> selectOpmEnvAccidentList(OpmEnvAccident opmEnvAccident) {
        return opmEnvAccidentMapper.selectOpmEnvAccidentList(opmEnvAccident);
    }

    /**
     * 新增环保事故
     *
     * @param opmEnvAccident 环保事故
     * @return 结果
     */
    @Override
    public int insertOpmEnvAccident(OpmEnvAccident opmEnvAccident) {
        opmEnvAccident.setId(IdUtil.getSnowflake(0, 0).nextId());
        opmEnvAccident.setCreateTime(DateUtils.getNowDate());
        opmEnvAccident.setCreateBy(SecurityUtils.getUsername());
        return opmEnvAccidentMapper.insertOpmEnvAccident(opmEnvAccident);
    }

    /**
     * 修改环保事故
     *
     * @param opmEnvAccident 环保事故
     * @return 结果
     */
    @Override
    public int updateOpmEnvAccident(OpmEnvAccident opmEnvAccident) {
        opmEnvAccident.setUpdateTime(DateUtils.getNowDate());
        opmEnvAccident.setUpdateBy(SecurityUtils.getUsername());
        return opmEnvAccidentMapper.updateOpmEnvAccident(opmEnvAccident);
    }

    /**
     * 批量删除环保事故
     *
     * @param ids 需要删除的环保事故ID
     * @return 结果
     */
    @Override
    public int deleteOpmEnvAccidentByIds(Long[] ids) {
        return opmEnvAccidentMapper.deleteOpmEnvAccidentByIds(ids);
    }

    /**
     * 删除环保事故信息
     *
     * @param id 环保事故ID
     * @return 结果
     */
    @Override
    public int deleteOpmEnvAccidentById(Long id) {
        return opmEnvAccidentMapper.deleteOpmEnvAccidentById(id);
    }
}
